<?php
/**
 * Copyright (C) 2009  Honghao Geng (genghonghao@gmail.com)
 * $Id: login.php 129 2009-08-04 02:10:32Z genghonghao $
 */
!defined('SMARTGOON_MAIN_LOADED') ? define('SMARTGOON_MAIN_LOADED', 1) : NULL;
require_once './config.php';
require_once './includes/common.php';
if (isset($_REQUEST['login_sub']))
{
	$username = trim($_REQUEST['loginname']);
	$password = md5(trim($_REQUEST['password']));
	$result = $db->result("SELECT COUNT(*) AS num FROM " . TB_ADMIN . " WHERE username='{$username}' AND password='{$password}'");
	if ($result[0]['num'] == 1)
	{
		$_SESSION['user']['islogin'] = TRUE;
		$_SESSION['user']['userid'] = 1;
		$_SESSION['user']['username'] = $username;
		$_SESSION['user']['userip'] = $client_ip;
		redirect_page($lang['login_success'],$lang['login_page_jump'],'./admincp/');
	}
	else 
	{
		redirect_page($lang['login_failure'],$lang['login_page_jump'],'./login.php');
	}
}
$tpl->display('login.html');
require_once './footer.php';
?>
